package com.tanhua.controller;

import com.tanhua.service.SmallVideosService;
import model.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/smallVideos")
public class SmallVideosController {
    @Autowired
    private SmallVideosService smallVideosService;

    @PostMapping
    public ResponseEntity saveVideos(
            MultipartFile videoThumbnail,
            MultipartFile videoFile) throws IOException {
        smallVideosService.saveVideos(videoThumbnail, videoFile);
        return ResponseEntity.ok(null);
    }

    @GetMapping
    public ResponseEntity queryVideoList(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pagesize) {
        PageResult result = smallVideosService.queryVideoList(page, pagesize);
        return ResponseEntity.ok(result);
    }
}
